package com.rm.zeyou.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.rm.zeyou.entity.UserCoupon;
import com.rm.zeyou.vo.response.SelectUserCouponListResponseVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * <p>
 * 用户优惠卷 Mapper 接口
 * </p>
 *
 * @author YanYang
 * @since 2025-03-12 15:55:09
 */
@Mapper
public interface UserCouponMapper extends BaseMapper<UserCoupon> {
    @Select("select count(*) from t_user_coupon  where user_id = #{id} and coupon_status = 'NOT'")
    Integer selectCouponCount(@Param("id")Long id);

    List<SelectUserCouponListResponseVo> selectUserCouponListByType(@Param("userId") Long userId, @Param("type") String type);

    @Update("update t_user_coupon set coupon_status = #{status} where id = #{userCouponId}")
    Integer updateUserCouponStatus(@Param("userCouponId") Long userCouponId, @Param("status") String status);

    List<SelectUserCouponListResponseVo> selectOrderCanUseCouponList(@Param("userId") Long userId, @Param("tid") Long tid);

}
